<template>
	<view class="page">
		<v-header title="完善企业信息" @click-left="$back()"></v-header>
		<view class="layout" :style="{ marginTop: h + 'px' }">
			<view class="loginBox">
				<view class="f cell">
					<text class="requierText">*</text>
					<label class="label gsname"></label>
					<input class="fl" type="text" v-model="query.qyname" placeholder="请输入注册企业名称" maxlength="30" />
				</view>

				<view class="f cell">
					<text class="requierText"></text>
					<label class="label date"></label>
					<picker class="picker fl" mode="date" :value="addquery.inspectionTime" @change="selectChange($event, 'jcTime')">
						<input v-model="query.date" disabled placeholder="请输入企业成立日期" maxlength="30" />
					</picker>
					<text class="cuIcon-right"></text>
				</view>
				<view class="f cell">
					<text class="requierText"></text>
					<label class="label name"></label>
					<input class="fl" type="text" v-model="query.name" placeholder="请输入联系人姓名" maxlength="30" />
				</view>
				<view class="f cell">
					<text class="requierText"></text>
					<label class="label phone"></label>
					<input class="fl" type="number" v-model="query.phone" placeholder="请输入联系人手机号" maxlength="30" />
				</view>
				<view class="f cell">
					<text class="requierText"></text>
					<label class="label email"></label>
					<input class="fl" type="text" v-model="query.email" placeholder="请输入联系人邮箱" maxlength="30" />
				</view>
				<view class="cu-btn block round login" @tap="submit">提 交</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			h: this.$h,
			query: {
				qyname: '',
				date: '',
				name: '',
				phone: '',
				email: ''
			}
		};
	},
	methods: {
		//选择时间
		selectChange(e, type) {
			let than = this;
			let index = e.target.value;
			if (type == 'jcTime') {
				//检查时间
				than.query.date = e.target.value;
			}
		},
		//提交
		submit() {
			let than = this;
			let qyname = than.query.qyname || '';
			let email = than.query.email || '';
			var reg = new RegExp('^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$'); //正则表达式
			if (!qyname || qyname == '') {
				uni.showToast({ title: '请输入企业注册名称', icon: 'none' });
				return false;
			} else if (email.length > 0) {
				if (!reg.test(email)) {
					uni.showToast({ title: '请输入有效邮箱地址', icon: 'none' });
					return false;
				}
			} else {
				uni.navigateTo({
					url: '../../views/login/examine'
				});
			}
		}
	}
};
</script>

<style lang="scss" scoped>
@import '@/common/style/login.scss';
.cuIcon-right {
	width: 40rpx;
}
</style>
